package com.yachang.qym.usbhost.adapter;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.yachang.qym.usbhost.R;
import com.yachang.qym.usbhost.model.OutPoliceModel;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by qinyuanmao on 2017/3/22.
 */

public class FloorAdapter extends RecyclerView.Adapter<FloorAdapter.ViewHolder>{

    private Context mContext;
    private Map<String, OutPoliceModel> mOutPoliceMap = new HashMap<>();
    public Map<Integer, List<OutPoliceModel>> mMap = new HashMap<>();

    public FloorAdapter(Context context/*, List<OutPoliceModel> outPoliceModel*/){
        mContext = context;/*
        mOutPoliceModels = outPoliceModel;
        for(int i = 0; i < outPoliceModel.size(); i++){
            List<OutPoliceModel> outPoliceModels = new ArrayList<>();
            if(outPoliceModel.get(i).getNowFloor() == i){
                outPoliceModels.add(outPoliceModel.get(i));
            }
            mMap.put(i, outPoliceModels);
        }*/
    }

    public void deleteOne(OutPoliceModel outPoliceModel){

    }

    public void changeOne(OutPoliceModel outPoliceModel){
        if(mOutPoliceMap.containsKey(outPoliceModel.get_id())){
            if(mOutPoliceMap.get(outPoliceModel.get_id()).getNowFloor() == outPoliceModel.getNowFloor()){
                
            } else {

            }
        } else {

        }
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        FloorAdapter.ViewHolder holder = new FloorAdapter.ViewHolder(LayoutInflater.from(
                mContext).inflate(R.layout.item_recyclerview, parent,
                false));
        return holder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {

    }

    @Override
    public int getItemCount() {
        return mMap.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder
    {
        public ViewHolder(View view)
        {
            super(view);
            recyclerView = (RecyclerView) view.findViewById(R.id.recycler_person);
            LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
            linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
            recyclerView.setLayoutManager(linearLayoutManager);
        }

        RecyclerView recyclerView;
    }
}
